<?php

namespace App\Listeners;

use App\Events\VipPurchasePaidEvent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class VipPurchasePaidListener
{
    public function handle(VipPurchasePaidEvent $event)
    {   

        if (!$event->vipPurchase->user->isRechargedVip()) {
            // bought as recharge.
            $event->vipPurchase->update(['is_new'=>true]);
        } 
	    $event->vipPurchase->user->boughtVip();
    }
}
